package com.itheima.jingjie.map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo3 {
    public static void main(String[] args) {
        Map<String ,String> map=new HashMap<String, String>();
        map.put("1号丈夫","1号妻子");
        map.put("2号丈夫","2号妻子");
        map.put("3号丈夫","3号妻子");
        map.put("4号丈夫","4号妻子");
        map.put("5号丈夫","5号妻子");
//        Set<String> strings = map.keySet();
//        for (String string : strings) {
//            String s=map.get(string);
//            System.out.println("键: "+string+"   值: "+s);
//        }
        keyset(map);
        System.out.println("................................");
//        Set<Map.Entry<String,String>> entryset=map.entrySet();
//        for (Map.Entry<String, String> stringStringEntry : entryset) {
//            String key = stringStringEntry.getKey();
//            String value = stringStringEntry.getValue();
//            System.out.println(key+"........"+value);
//        }
        System.out.println("................................");
        entryMap(map);
    }

    public static void keyset(Map<String, String> map) {
        Set<String> strings = map.keySet();
        for (String string : strings) {
            String s=map.get(string);
            System.out.println("键: "+string+"   值: "+s);
        }
    }

    public static void entryMap(Map<String, String> map) {
        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println("键: "+key+"  值: "+value);
        }
    }
}
